﻿using Inovout.Kuajing.Models;
using Inovout.Memberships.Models;
using Inovout.Services;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Kuajing.Services
{
    public class ConsignerService : RepositoryService<Consigner>
    {
        public Consigner FindConsignerByMembership(Membership membership)
        {
          Actor actor = membership.Actors.Where(n => n.Membership.Id == membership.Id).Single();
          return base.Repository.FindById(actor.Id);    
        }


        public Consigner FindConsignerByLoginName(string loginName)
        {
            return base.Repository.Find(Restrictions.Eq("LoginName", loginName));
        }
    }
}
